<template>
	<view class="miou-studio-box">
		<!--标题栏-->
		<bar-title  bgColor='bg-white'>
			<block slot="content">发行信息</block>
		</bar-title>

		<view class="container bg-white">
			<view class="studio-list padding">
				<view class="grid col-3">
					<block v-for="(item, index) in studioList " :key="index">
						<view class="text-center margin-bottom-xl "
							@click="jumpStudio(item)"
						>
							<view class="cu-avatar round" 
							:style="'background-image:url('+item.tlssimg+');'"
							></view>
							<view class="padding-top-sm text-sm">{{item.lssuername}}</view>
						</view>
					</block>
				</view>
			</view>
			
			<uni-load-more :status="loadingType"></uni-load-more>
		</view>
		
	</view>
</template>

<script>
import uniLoadMore from '@/components/basics/uni-load-more/uni-load-more.vue';
import { Publisher } from '@/models/publisher.js';
export default {
	name: 'publisher',
	components: {
		uniLoadMore
	},
	data() {
		return {
			pagenum: 1,
			loadingType: 'more',
			studioList:[]
		}
	},
	onLoad() {
		this.getPublisher(this.pagenum)
	},
	methods: {
		async getPublisher(pagenum) {
			this.loadingType = 'loading'
			let studioList =  await Publisher.getAllPublisher(pagenum)
			this.studioList = this.studioList.concat(studioList)
			if (studioList.length < 20) {
				this.loadingType = 'noMore'
				return
			}
			this.loadingType = 'more'
		},
		jumpStudio(item) {
			this.$store.commit('setStateAttr', {
				key: 'curretPublisher',
				val: item
			}) 
			this.$jumpPages('studioDetail', {
				lssuerid: item.lssuerid
			})
		}
	},
	onReachBottom(e) {
		if(this.loadingType == 'loading' || this.loadingType == 'noMore'){
			return
		}
		this.pagenum = this.pagenum + 1
		this.getPublisher(this.pagenum)
	},
}
</script>
